'use strict';

module.exports = function ($scope, $modal, $log, $http) {

$scope.uploadFile = function(files) {
    var fd = new FormData();
    //Take the first selected file
    fd.append("file", files[0]);

    $http.post('http://localhost:8180/cooparties/upload', fd, {
        withCredentials: true,
        headers: {'Content-Type': undefined },
        transformRequest: angular.identity
    });
    //changer le nom du fichier en idutilisateur + timestamp + extension et 
    //stocker le nom du fichier en base de données
};

  $scope.demandeSupressionCompte = function (size) {

    var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: ModalInstanceCtrl,
      size: size
    });

    modalInstance.result.then(function () {
      $log.info('Modal closed at: ' + new Date());
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });
  };


  var ModalInstanceCtrl = function ($scope, $modalInstance) {
    $scope.ok = function () {
      $modalInstance.close();
    };

    $scope.cancel = function () {
      $modalInstance.dismiss('cancel');
    };

  };

};